var api = require("../../api.js");
const app = getApp();
Page({
  data: {
    info:[],
    act_modal_list:[
      {
        active_color: "#ff4544",
        active_icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-index.active.png",
        color: "#888",
        icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-index.png",
        new_url: "/pages/edit_index/edit_index",
        text: "商城",
        index:0
      },
      {
        active_color: "#ff4544",
        active_icon: 'http://ys.mingsxx.com/uploads/image/store_1/5fbf9630ab800.png',
        color: "#888",
        icon: 'http://ys.mingsxx.com/uploads/image/store_1/5fbf9358eb189.png',
        new_url: "/pages/vip/vip",
        text: "关于马库",
        url: "/pages/vip/vip",
        index:1
      },
      // {
      //   active_color: "#ff4544",
      //   active_icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-cat.active.png",
      //   color: "#888",
      //   icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-cat.png",
      //   new_url: "/pages/cat/cat",
      //   text: "分类",
      //   url: "/pages/cat/cat",
      //   index:1
      // },
      {
        active_color: "#ff4544",
        active_icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-cart.active.png",
        color: "#888",
        icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-cart.png",
        new_url: "/pages/cart/cart",
        text: "购物车",
        url: "/pages/cart/cart",
        index:2
      },
      {
        active_color: "#ff4544",
        active_icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-user.active.png",
        color: "#888",
        icon: "http://ys.mingsxx.com/web/statics/images/appnavbar/nav-icon-user.png",
        new_url: "/pages/user/user",
        text: "我",
        url: "/pages/user/user",
        index:3
      }
    ]
  },
  onLoad: function (options) {
    let _self = this;
    app.request({
      url: api.default.index,
      data: {},
      method: "POST",
      success: function(t) {
        let res = t.data.module_list_2;
        let info = [];
        res.forEach(item=>{
          if(item.module_name === 'vip'){
            info = item.content
          }
        });
        _self.setData({
          info
        })
        console.log(info)
      }
    })
  },
  toPath(e){
    console.log(e)
    let index = e.currentTarget.dataset.id;
    let url = this.data.act_modal_list[index].new_url;
    console.log(index,url)
    if(index == 0){
      wx.switchTab({
        url:url
      })
    }else{
      wx.navigateTo({
        url:url
      })
    }

  },
  onShareAppMessage: function(){
    let share = {
      title:'关于马库',
      path:'/pages/vip/vip'
    };
    return share
  },
});
